/*
 * 文  件   名: CategoryManagerImpl.java
 * 版         本 : docrepository-server(Anttribe). All rights reserved.
 * 描         述 : <描述>
 * 修   改  人: zhaoyong
 * 修改时间: 2014年10月9日
 */
package org.anttribe.docrepository.category.manager.impl;

import java.util.List;

import org.anttribe.docrepository.category.dao.CategoryDao;
import org.anttribe.docrepository.category.domain.Category;
import org.anttribe.docrepository.category.manager.CategoryManager;
import org.anttribe.docrepository.common.UnifyException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;

/**
 * @author zhaoyong
 * @version 2014年10月9日
 */
public class CategoryManagerImpl implements CategoryManager
{
    /**
     * LOGGER
     */
    private static final Logger LOGGER = LoggerFactory.getLogger(CategoryManagerImpl.class);
    
    /**
     * categoryDao
     */
    private CategoryDao categoryDao;
    
    @Override
    public List<Category> getCategoryByPagination(int fromIndex, int toIndex)
        throws UnifyException
    {
        return categoryDao.queryAll();
    }
    
    @Override
    public void saveOrUpdateCategory(Category category)
        throws UnifyException
    {
        Assert.notNull(category);
        
        LOGGER.debug("save or update category");
        
        int count = categoryDao.insert(category);
        
        LOGGER.debug("save or update category end, result: {} the data is affected.", count);
    }
    
    public CategoryDao getCategoryDao()
    {
        return categoryDao;
    }
    
    public void setCategoryDao(CategoryDao categoryDao)
    {
        this.categoryDao = categoryDao;
    }
}